package com.example.voucher.enums;

import com.example.voucher.common.VoucherConstant;

public enum VoucherScenarioEnum {

    SaleInvoice(VoucherConstant.VOUCHER_SCENARIO_SALES_INVOICE, "销项发票"),
    PurchaseInvoice(VoucherConstant.VOUCHER_SCENARIO_PURCHASE_INVOICE, "进项发票"),
    PurchaseInvoice_GOODS(VoucherConstant.VOUCHER_SCENARIO_PURCHASE_INVOICE_GOODS, "进项发票(货款)"),
    PurchaseInvoice_EXPENSE(VoucherConstant.VOUCHER_SCENARIO_PURCHASE_INVOICE_EXPENSE, "进项发票(费用)");

    private String code;
    private String desc;

    private VoucherScenarioEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static VoucherScenarioEnum getByCode(String code) {
        for (VoucherScenarioEnum e : VoucherScenarioEnum.values()) {
            if (e.code.equals(code)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        for (VoucherScenarioEnum e : VoucherScenarioEnum.values()) {
            if (e.code.equals(code)) {
                return e.getDesc();
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
